package managers;

import structures.Product;
import structures.ProductList;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

public class JsonManager {

	public String generateJSON(Object object) {
		String jsonAnswer;
		Gson gson;
		gson =  new GsonBuilder().setPrettyPrinting().create(); 
		jsonAnswer =gson.toJson(object);
		return jsonAnswer;
	}
	
	public ProductList toProductList(String json) {
		Gson gson;
		gson = new GsonBuilder().create();
		return gson.fromJson(json, ProductList.class);
	}
	
	public Product toProduct(String json) {
		Gson gson;
		gson = new GsonBuilder().create();
		return gson.fromJson(json, Product.class);
	}
	
	
}
